package L623;

import java.util.Arrays;
import java.util.Collections;

/**
 * @program: javase
 * @description:
 * @author: luolidong
 * @create: 2021-06-23 09:47
 * @version: 1.0
 */
public class Demo1 {
    StringBuilder builder = new StringBuilder();

    public String reverseWords(String s) {
        String[] s1 = s.split(" ");
        for (String s2 : s1) {
            reverse(s2);
        }
        return builder.substring(0, builder.length() - 1);
    }

    private void reverse(String s2) {
        for (int i = s2.length() - 1; i >= 0; i--) {
            builder.append(s2.charAt(i));
        }
        builder.append(" ");
    }
}
